///////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Filename:		TinyLog.h
//	Author:			Andrew Ciervo
//	Version:		1.0
//	Date Created:	October 30, 2013
//	Date Modified:	November 5, 2013
//	Notes:			Creates a log file for use of debugging, tracing, and general usage.
///////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////
//	Standard Header Protection
////////////////////////////////////////////////////////////////////////////////////////
#ifndef _OBJECTLOADER_H_
	#define _OBJECTLOADER_H_
#endif	_OBJECTLOADER_H_

////////////////////////////////////////////////////////////////////////////////////////
//	Includes
////////////////////////////////////////////////////////////////////////////////////////
#include <fstream>		
using namespace std;	

#if defined(_WIN32) || defined(_WIN64)		// We are running Windows
	#ifndef WIN32_LEAN_AND_MEAN
		#define WIN32_LEAN_AND_MEAN
	#endif  WIN32_LEAN_AND_MEAN
	#include <Windows.h>
#elif defined(__APPLE__)					// We are running an Apple computer
	#include <unistd.h>
#elif defined(__linux__)					// We are running Linux
	#include <unistd.h>
#endif

////////////////////////////////////////////////////////////////////////////////////////
//	Exit Code Enumeration																
////////////////////////////////////////////////////////////////////////////////////////
enum ExitCode
{
	success				= 0x0,				// Decimal value equals 0
	file_not_found		= 0x1,				// Decimal value equals 1
	failed_to_load		= 0x2,				// Decimal value equals 2
	failed_to_read		= 0x4,				// Decimal value equals 4
	failed_to_write		= 0x8,				// Decimal value equals 8
	end_of_file			= 0x10,				// Decimal value equals 16
	failed_to_close		= 0x20,				// Decimal value equals 32
	invalid_filepath	= 0x40,				// Decimal value equals 64
	invalid_filename	= 0x80,				// Decimal value equals 128
};

////////////////////////////////////////////////////////////////////////////////////////
//	Class:	TinyLog
//	Notes:	Going to encapslate the File I/O of debugging, tracing, and general usage.
////////////////////////////////////////////////////////////////////////////////////////
class TinyLog
{

////////////////////////////////////////////////////////////////////////////////////////
//	Section:	Public
//	Notes:		Any function that the user can see and 
//				use without any restrictions
////////////////////////////////////////////////////////////////////////////////////////
public:
	
	//=========================================================================
	//	Function:	Constructor
	//	Params:		
	//	Return:		
	//	Notes:		Default Constructor
	//=========================================================================
	TinyLog( void );

	//=========================================================================
	//	Function:	Destructor
	//	Params:		
	//	Return:		
	//	Notes:		Cleans up any memory that is used.
	//=========================================================================
	~TinyLog( void );

	//=========================================================================
	//	Function:	Initialize
	//	Params:		void
	//	Return:		void
	//	Notes:		Sets up the data members that are used in saving or 
	//				loading a file.
	//=========================================================================
	void Initialize( void );

	//=========================================================================
	//	Function:	Uninitialize
	//	Params:		void
	//	Return:		void
	//	Notes:		Cleans up an instance of the class completely.
	//=========================================================================
	void Uninitialize( void );

	//=========================================================================
	//	Function:	OpenFile
	//	Params:		void
	//	Return:		bool
	//	Notes:		Safely opens a file.  
	//=========================================================================
	bool OpenFile( const char* filePath, const char* fileName, ios_base::open_mode openMode = ios_base::out );

	//=========================================================================
	//	Function:	CopyFile
	//	Params:		void
	//	Return:		bool
	//	Notes:		Copies the first file into the second file.
	//=========================================================================
	bool CopyFiles( const char* firstFileName, const char* secondFileName );

	//=========================================================================
	//	Function:	WriteFile
	//	Params:		void
	//	Return:		bool
	//	Notes:		Safely write to a file with the function name, function 
	//				description, and the result of said function.  
	//				Future use might include variadic functions and ... for
	//				unlimited use of writing to the file.
	//=========================================================================
	bool WriteFile( const char* functionName, const char* description, ExitCode code = ExitCode::success );

	//=========================================================================
	//	Function:	Initialize
	//	Params:		void
	//	Return:		bool
	//	Notes:		Safely closes the currently open file in the current
	//				instance of the class.
	//=========================================================================
	bool CloseFile( void );


////////////////////////////////////////////////////////////////////////////////////////
//	Section:	Private
//	Notes:		Any function that the user cannot see or use without an Accessor
//				or mutator function that is placed in the public section
////////////////////////////////////////////////////////////////////////////////////////
private:

	//=========================================================================
	//	Function:	GetLocalSystemTime
	//	Params:		string
	//	Return:		void
	//	Notes:		Gets the local time from the computers system, and returns
	//				it through the parameter.
	//=========================================================================
	void GetLocalSystemTime( string&  timeOutput );
	
	//=========================================================================
	//	Section:	Data members
	//=========================================================================
	SYSTEMTIME	sysTime;

	fstream		fileStream;
	char*		filePath;
	char*		fileName;

};
////////////////////////////////////////////////////////////////////////////////////////